home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 2002 January / PC Answers January 2002.7z / PC Answers January 2002.bin / graphics / freepixl / _SETUP.1 / cplapplt.pxl < prev    next >
Text File  |  2001-03-25  |  7KB  |  256 lines

  1. {    Filename    :     CPLapplets.pxl
  2.      Purpose    :    Windows shell and applets
  3.     Date        :    20 sep 99
  4.     Author    :        S.Dibbs, VYSOR Integration Inc
  5. History:
  6.  
  7.     Version    :  1.0    RELEASE
  8.     Update    :  
  9.     Date    :  
  10.  
  11. --------------------------------------------------------------------------}
  12. Initialize: {only one instance allowed}
  13.     UseCoordinates(PIXEL)
  14.     Title$ = "PiXCL 5.0 and the Control Panel Applets"
  15.  
  16.     WinExist(Title$,Res)
  17.     If Res = 0 Then Goto One_Instance
  18.     Beep
  19.     WinSetActive(Title$,Res)
  20.     WinShow(Title$,RESTORE,Res)
  21.     End
  22. One_Instance:
  23.     UseCaption(Title$) {change the title}
  24.     WinLocate(Title$,472,188,970,594,Res)                
  25.     UseBackground(TRANSPARENT,0,128,128)     
  26.     WinShow(Title$,NOTOPMOST,Res) 
  27.     DrawBackGround
  28.     DirGet(SourceDir$) {used later for library function calls}
  29.     DirGetWindows(WinDir$)
  30.     DirGetSystem(WinSys$)
  31.     WinVersion(Major,Minor,Build,Pack$)
  32.  
  33.     DrawText(10,40,"Windows version detected ...")
  34.     DrawNumber(10,60, Major)
  35.     DrawNumber(30,60, Minor)
  36.     DrawNumber(60,60, Build)
  37.     DrawText(100,60,Pack$)
  38.  
  39.     If Build <> 950 
  40.         If Build <> 2222
  41.         WinDir$ = WinSys$
  42.         Endif
  43.     Endif
  44.     If Major = 5 Then WinDir$ = WinSys$ { Windows 2000}
  45.  
  46.     InfoMenu(REMOVE)
  47.     WaitInput(100)
  48.  
  49.     SetMenu("&File",IGNORE,
  50.         "&New",CreatingFile,
  51.         "&Test Applets",OpeningFile,
  52.         "&Format Floppy",FormatFloppy,
  53.         SEPARATOR,
  54.         "E&xit!",Terminate,
  55.         ENDPOPUP,
  56.         "&View",IGNORE,
  57.         "&ToolBar",ViewToolBar,
  58.         "&StatusBar",ViewStatusBar,
  59.         ENDPOPUP,
  60.         "&Information",IGNORE,
  61.         "&Concept",Concept,
  62.         "&Help",ShowAppHelp,
  63.         SEPARATOR,
  64.         "&About",About,
  65.         ENDPOPUP)
  66.  
  67.     GoSub MakeToolbar
  68.     ChangeMenuItem("&ToolBar",CHECK,TBRes)
  69.  
  70.         
  71.     StatusWindow(ENABLE,BOTTOM,2,500,-1,0,0)
  72.     DrawStatusWinText(0,"Ready")
  73.     ChangeMenuItem("&StatusBar",CHECK,SBRes)
  74.     PiXCLInstDir$ = ""
  75.  
  76. Wait_for_Input:
  77.     WaitInput()
  78.  
  79. Terminate:
  80.     WinHelp("PiXCL Help v4.4" ,QUIT,"")
  81.     End
  82.  
  83.  
  84. Concept:
  85.     MessageBox(OK,1,INFORMATION,
  86. "This sample file opens the various control panel applet files
  87. located in the Windows system directory, and demonstrates the 
  88. functions available within the applet.",
  89.     Title$,Res)
  90.  
  91.     Goto Wait_for_Input
  92.  
  93. ShowAppHelp:
  94.     {An application Help file usually has the same name as the application. Here,
  95.       we get the help topic in the PiXCL help file. The PiXCL install directory is 
  96.       stored in the Registry.} 
  97.  
  98.     If PiXCLInstDir$ = ""
  99.         RDBOpenKey(@RDB_CURRENT_USER,
  100.         "Software\VYSOR Integration Inc\PiXCL MDI Editor\Settings",OutHandle1)
  101.         RDBQueryValue(OutHandle1,"InstDir",PiXCLInstDir$ ,Res)
  102.         RDBCloseKey(OutHandle1,Res)
  103.     Endif
  104.     
  105.     HelpFile$ = PiXCLInstDir$ + "\pixclhlp.hlp"
  106.     WinHelp(HelpFile$,KEY,"Using the Windows Shell functions with PiXCL")
  107.  
  108.     Goto Wait_for_Input
  109.  
  110. About:
  111.     AboutUser(Title$,
  112.       "Identifying the Control Panel Applets.",
  113.     "Selects a Control Panel applet and check the contents by running a
  114. Windows shell command.")
  115.  
  116.     Goto Wait_for_Input
  117.  
  118. ViewToolBar:
  119.     GetMenuStatus("&ToolBar",CHECKED,Res)
  120.     If Res = 0
  121.         GoSub MakeToolbar
  122.         ChangeMenuItem("&ToolBar",CHECK,Res)
  123.     Else
  124.         Toolbar()
  125.         ChangeMenuItem("&ToolBar",UNCHECK,Res)
  126.     Endif
  127.     Goto Wait_for_Input
  128.  
  129. ViewStatusBar:
  130.     GetMenuStatus("&StatusBar",CHECKED, Res)
  131.     If Res = 0
  132.         StatusWindow(ENABLE,BOTTOM,2,500,-1,0,0)
  133.         DrawStatusWinText(0,"Ready")
  134.         ChangeMenuItem("&StatusBar",CHECK,Res)
  135.     Else
  136.         StatusWindow(DISABLE,BOTTOM,2,500,-1,0,0)
  137.        ChangeMenuItem("&StatusBar",UNCHECK,Res)
  138.     Endif
  139.     Goto Wait_for_Input
  140.  
  141. CreatingFile:
  142.     {TODO: add file handling here
  143.     MessageBox(OK,1,EXCLAMATION,
  144.         "Look at the source code, at label 'CreatingFile:'",
  145.         "No function coded for this button",Res)  }
  146.  
  147.     Cmd$ = "c:\windows\rundll32.exe amovie.ocx,RunDll /play /close /center HVSCmp.avi "
  148.     Run(Cmd$)
  149.     Goto Wait_for_Input
  150.  
  151. OpeningFile:
  152.     WaitInput(1)
  153.     Filter$ = "Control Panel Applets (*.cpl),*.cpl"
  154.     InitFile$ = "*.cpl"
  155.     Label$ = "Select a Control Panel Applet file to examine."
  156.     FileGet(Filter$,InitFile$,WinSys$,Label$,CHANGEDIR,CPLfile$)
  157.     If CPLfile$ = "" Then Goto Wait_for_Input
  158.     
  159.     {Loop through the CPL file arguments and see what these applets do}
  160.     Ansi("0",Index)
  161.     Cmd$ = WinDir$ + "\rundll32.exe shell32.dll,Control_RunDLL "
  162.     Cmd$ = Cmd$ + CPLfile$ + ",@"
  163.     Chr(Index,App$)
  164.     CmdLine$ = Cmd$ + App$ 
  165.     {CmdLine$ = CmdLine$ + ",0"  {add extra to select property page}}
  166.     RightOf(CmdLine$,50,Rpt$)
  167.     DrawStatusWinText(0,Rpt$)
  168.     WaitInput(100)
  169.     DebugMsgBox(CmdLine$)
  170.     Run(CmdLine$)
  171.  
  172. Loop:
  173.     MessageBox(YESNO,1,QUESTION,
  174.         "Get next applet ? If no new applet dialog appears, click No",CPLfile$,Res)
  175.     If Res = 2 Then DrawStatusWinText(0,"Ready") Goto Wait_for_Input
  176.     WaitInput(100) 
  177.     Index++
  178.     Chr(Index,App$)
  179.     CmdLine$ = Cmd$ + App$
  180.     {CmdLine$ = Cmd$ + "0," + App$ } {add extra to select property page}
  181.     RightOf(CmdLine$,50,Rpt$)
  182.     DrawStatusWinText(0,Rpt$)
  183.     WaitInput(100)
  184.     {DebugMsgBox(CmdLine$)}
  185.     Run(CmdLine$)
  186.     Goto Loop
  187.  
  188. FormatFloppy:
  189.     WaitInput(1)
  190.     Cmd$ = WinDir$ + "\rundll32.exe shell32.dll,SHFormatDrive"
  191.     Run(Cmd$) 
  192.     {This displays a modeless dialog that accepts input, and PiXCL will
  193.       go back to the idle loop unless code, such as below, is used.}
  194. {
  195.     FormatWin$ = "Format - 3╜ Floppy (A:)"
  196.     WinExist(FormatWin$,Res)
  197.     If Res = 1
  198.         While Res = 1
  199.             WinExist(FormatWin$,Res)
  200.         EndWhile
  201.     Endif
  202. }
  203.     Goto Wait_for_Input
  204.  
  205.  
  206. OpenWithDlg:
  207.     WaitInput(1)
  208.     Cmd$ = WinDir$ + "\rundll32.exe shell32.dll,OpenAs_RunDLL c:\temp\bob.ump"
  209.     Run(Cmd$) 
  210. {     NOTES:
  211.     If file type *.ump is unknown, an edit control appears into which you can type
  212.     a description. If the file type is known (ie an entry in the Registry), the Description
  213.     control does not appear.
  214. }
  215.     Goto Wait_for_Input
  216.  
  217. ShowControlPanel:
  218.     WaitInput(1)
  219.     Cmd$ = WinDir$ + "\rundll32.exe shell32.dll,Control_RunDLL"  {show the control panel}
  220.     Cmd$ = WinDir$ + "\control.exe"
  221.     Run(Cmd$) 
  222.     Goto Wait_for_Input
  223.  
  224. {--- Style Suggestion: place all subroutines at the end of the script.}
  225.  
  226. MakeToolbar: {subroutine}
  227.     Toolbar(RAISED, PXL_LARGE,
  228.         NULL, NULL, SEPARATOR, "", Wait_for_Input,
  229.         PXL_NEW, ENABLED, STD, "FileNew", CreatingFile,
  230.         PXL_OPEN, ENABLED, STD, "Test Applets", OpeningFile,
  231.         PXL_SAVE, ENABLED, STD, "Format Floppy", FormatFloppy,
  232.         PXL_PROP,  ENABLED, STD,"''Open With'' Dialog", OpenWithDlg,
  233.         PXL_ADDTOFAVORITES,  ENABLED, STD,"Display Control Panel",ShowControlPanel,
  234.         NULL, NULL, SEPARATOR, "", Wait_for_Input,
  235.         HELPINFO, ENABLED, STD,"Show Help",ShowAppHelp)
  236.  
  237.     Return
  238.  
  239.  
  240. { ============================================================
  241. Notes on using rundll32.exe
  242.  
  243. rundll32.exe <dllname>,<entrypoint> <optional arguments> 
  244.  
  245. <dllname>     is not case sensitive, because its a filename. Is usually a DLL, but can also be
  246.         an EXE file.
  247. ,<entrypoint>     This IS case-sensitive. Note that there is no space before or after the comma. Put
  248.         in a space and the command will fail.
  249.  
  250. <optional arguments> 
  251.         filenames and other arguments
  252. Examples:
  253.     amovie.ocx,RunDll c:\windows\clock.avi /play /close
  254.  
  255.  
  256. }